package com.beans;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/*
* Setter 注入：早期 Spring 版本推荐的写法，
*               Setter 注入通用性没有构造方法注入通用
*
* */

@Controller
public class UserController4 {

    //3.通过 setter 注入
    private UserService userService;

    @Autowired
//    @Resource
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public void sayHi(){
        userService.sayHi();
    }

}
